<template>
  <div class="container">
    <div class="timeline">
      <div class="header">
        <div class="title">
          <img style="width: 20px" src="@/assets/images/dashboard/dec@2x.png" />
          <div class="text">泳道图</div>
        </div>
        <div class="button-explain">
          <div class="explain-self"
            ><icon-exclamation-circle-fill />本团队图例</div
          >
          <div class="explain-other"
            ><icon-exclamation-circle-fill />其他团队图例</div
          >
        </div>
      </div>
      <upload-timeline
        v-if="filterData.length > 0"
        :data="filterData"
      ></upload-timeline>
      <div class="button-box">
        <div
          v-if="showButtonSwitch === 0"
          class="loadmore-button"
          @click="loadmore"
        >
          <img src="@/assets/images/design/load-more.png" />
        </div>
        <div v-if="showButtonSwitch === 1" class="middle-button">
          <div class="close-button">
            <div class="loadmore-button" @click.stop="loadmore2">
              <icon-down size="20" />
            </div>
            <icon-close class="close-icon" size="20" @click="close" />
          </div>
        </div>
        <div v-if="showButtonSwitch === 2" class="middle-button">
          <div class="close-button">
            <div class="loadmore-button" @click.stop="loadmore">
              <icon-up size="20" />
            </div>
            <icon-close class="close-icon" size="20" @click="close" />
          </div>
        </div>
      </div>
    </div>
    <file-table></file-table>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue';
  import UploadTimeline from './components/upload-timeline.vue';
  import FileTable from './components/table-file.vue';

  const showButtonSwitch = ref(0);

  const data = [
    {
      groupName: '线路总体',
      uploadHistory: [
        { uploadTime: new Date('2022/09/01 22:00'), filePath: '', type: 4 },
        { uploadTime: new Date('2022/09/01 22:00'), filePath: '', type: 4 },
        { uploadTime: new Date('2022/09/01 22:40'), filePath: '', type: 4 },
        { uploadTime: new Date('2022/09/6 22:00'), filePath: '', type: 1 },
        { uploadTime: new Date('2022/10/6 22:00'), filePath: '', type: 1 },
        { uploadTime: new Date('2022/11/01 22:00'), filePath: '', type: 3 },
        { uploadTime: new Date('2022/12/01 22:00'), filePath: '', type: 4 },
        { uploadTime: new Date('2023/01/01 12:00'), filePath: '', type: 5 },
        { uploadTime: new Date('2023/01/06 12:00'), filePath: '', type: 5 },
        { uploadTime: new Date('2023/03/01 12:00'), filePath: '', type: 7 },
        { uploadTime: new Date('2023/04/01 12:00'), filePath: '', type: 8 },
        { uploadTime: new Date('2023/09/01 12:30'), filePath: '', type: 4 },
      ],
    },
    {
      groupName: '路基路面',
      uploadHistory: [
        { uploadTime: new Date('2022/05/01 22:00'), filePath: '', type: 2 },
        { uploadTime: new Date('2023/02/01 12:00'), filePath: '', type: 2 },
        { uploadTime: new Date('2023/02/03 12:00'), filePath: '', type: 4 },
        { uploadTime: new Date('2023/02/05 12:00'), filePath: '', type: 4 },
        { uploadTime: new Date('2023/02/07 12:00'), filePath: '', type: 8 },
        { uploadTime: new Date('2023/05/07 12:00'), filePath: '', type: 8 },
        { uploadTime: new Date('2023/05/09 12:00'), filePath: '', type: 8 },
      ],
    },
    {
      groupName: '桥梁',
      uploadHistory: [
        { uploadTime: new Date('2022/06/01 11:50'), filePath: '', type: 6 },
        { uploadTime: new Date('2022/06/01 12:00'), filePath: '', type: 6 },
      ],
    },
  ];

  const filterData = ref<any[]>([]);

  const loadmore = () => {
    showButtonSwitch.value = 1;
    filterData.value = [data[0]];
  };
  const loadmore2 = () => {
    showButtonSwitch.value = 2;
    filterData.value = data;
  };
  const close = () => {
    showButtonSwitch.value = 0;
    filterData.value = [];
  };
</script>

<style lang="less" scoped>
  .container {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
  }
  .timeline {
    border-bottom: 1px solid var(--color-border);
    padding: 0 44px;
    width: 100%;
    border-radius: 8px;
    position: relative;
    transition: height 0.2s ease-out;
  }
  .button-box {
    width: 80px;
    height: 38px;
    position: absolute;
    bottom: -38px;
    left: 50%;
    border: 1px solid var(--color-border);
    border-top: 1px solid var(--color-bg-1);
    border-radius: 0 0 8px 8px;
    .loadmore-button {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      margin-top: -4px;
      cursor: pointer;
      img {
        width: 72px;
        height: 37px;
      }
    }
    .middle-button {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;
      .close-button {
        width: 68px;
        height: 32px;
        background-color: rgb(235, 240, 255);
        color: #3366ff;
        border-radius: 4px;
        position: relative;
        margin-top: -4px;
        .loadmore-button {
          height: 32px;
          width: 32px;
          background-color: #3366ff;
          color: var(--color-bg-1);
          display: flex;
          justify-content: center;
          align-items: center;
          border-radius: 4px;
          position: absolute;
          top: 4px;
        }
        .close-icon {
          position: absolute;
          left: 40px;
          top: 6px;
        }
      }
    }
  }
  .header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    .title {
      display: flex;
      img {
        margin-right: 8px;
      }
      .text {
        color: var(--color-text-1);
        font-size: 18px;
        font-weight: 500;
      }
    }
    .button-explain {
      display: flex;
      align-items: center;
      .explain-self {
        color: #f76560;
        margin-right: 16px;
      }
      .explain-other {
        color: #3366ff;
      }
    }
  }
  .file {
    width: 100%;
    padding: 24px 44px 0 44px;
    flex: 1;
  }
  .file-header {
    font-size: 18px;
    font-weight: 500;
    margin: -24px 0 24px 0;
    display: flex;
    img {
      margin-right: 8px;
    }
    .text {
      color: var(--color-text-1);
      font-size: 18px;
      font-weight: 500;
    }
  }
</style>
